
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="styles/styles.css" type="text/css" />
<title>Query Checker</title>
<!--<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="scripts/scripts.js"></script>-->
<link href='http://fonts.googleapis.com/css?family=Dosis' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="container" class="one-edge-shadow">
  <div id="mainContent">
 <?php
session_start();
if (!isset($_SESSION['studentID'])) 
{ 
$studentID = 136;
}
if (!isset($_SESSION['testID'])) 
{ 
$testID = 1;
}
////////////////////////////////////////////////////////////////////////
//										     		  			STUDENT
//////////////////////////////////////////////////////////////////////
function student() {
$studentID = 136;
$testID = 1;

$con = mysqli_connect("localhost","root","Frankie28","dblr12aas");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries
$result = mysqli_query($con,"SELECT * FROM student WHERE studentID = "
. "'" . $studentID . "'");

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	$S_studentID = $row["studentID"];
	$S_lastName = $row["lastName"];
	$S_firstName = $row["firstName"];
	$S_Username = $row["username"];
	$S_dateCreated = $row["dateCreated"];
}

echo 'studentID: ' . $S_studentID . '<br/>';
echo 'First name: ' . $S_firstName . '<br/>';
echo 'Last name: ' . $S_lastName. '<br/>'; 
echo 'Username: ' . $S_Username. '<br/>';
echo 'dateCreated: ' . $S_dateCreated. '<br/>';
}

////////////////////////////////////////////////////////////////////////
//										     		   STUDENT RESPONSE
//////////////////////////////////////////////////////////////////////
function studentresponse() {
$studentID = 136;
$testID = 1;
$con = mysqli_connect("localhost","root","Frankie28","dblr12aas");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries
$result = mysqli_query($con,"SELECT * FROM studentresponse WHERE studentID = "
. "'" . $studentID . "'");
$rows = array();
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	array_push($rows, $row);
}

return $rows;
}

////////////////////////////////////////////////////////////////////////
//										     		   STUDENT IN TEST
///////////////////////////////////////////////////////////////////////
function studentintest() {
$studentID = 136;
$testID = 1;
$con = mysqli_connect("localhost","root","Frankie28","dblr12aas");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries
$result = mysqli_query($con,"SELECT * FROM studentintest WHERE studentID = "
. "'" . $studentID . "'");

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	$SIT_studentID = $row["studentID"];
	$SIT_testID = $row["testID"];
	$SIT_startTime = $row["startTime"];
	$SIT_endTime = $row["endTime"];
	$SIT_finalScore = $row["finalScore"];
	$SIT_attempt = $row["attempt"];
}

echo 'studentID: '. $SIT_studentID . '<br/>';
echo 'testID: '. $SIT_testID . '<br/>';
echo 'startTime: '. $SIT_startTime . '<br/>';
echo 'endTime: '. $SIT_endTime . '<br/>';
echo 'finalScore: '. $SIT_finalScore . '<br/>';
echo 'attempt: '. $SIT_attempt . '<br/>';
}

////////////////////////////////////////////////////////////////////////
//										     		      		   TEST
//////////////////////////////////////////////////////////////////////
function test() {
$studentID = 136;
$testID = 1;
$con = mysqli_connect("localhost","root","Frankie28","dblr12aas");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries
$result = mysqli_query($con,"SELECT * FROM test WHERE testID = "
. "'" . $testID . "'");

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	$T_testID = $row["testID"];
	$T_testDescription = $row["testDescription"];
	$T_createdAt = $row["createdAt"];
}

echo 'testID: '. $T_testID . '<br/>';
echo 'testDescription: '. $T_testDescription . '<br/>';
echo 'createdAt: '. $T_createdAt . '<br/>';
}

////////////////////////////////////////////////////////////////////////
//										     		      	    QUESTION
///////////////////////////////////////////////////////////////////////
function question() {
$studentID = 136;
$testID = 1;
$con = mysqli_connect("localhost","root","Frankie28","dblr12aas");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries
$result = mysqli_query($con,"SELECT * FROM questions");

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	$Q_itemID = $row["itemID"];	
	$Q_stem = $row["stem"];
	$Q_option1 = $row["option1"];
	$Q_option2 = $row["option2"];
	$Q_option3 = $row["option3"];
	$Q_option4 = $row["option4"];
	$Q_correctAnswer = $row["correctAnswer"];
	$Q_resource = $row["resource"];
}

echo 'itemID: '. $Q_itemID . '<br/>';
echo 'stem: '. $Q_stem . '<br/>';
echo 'option1: '. $Q_option1 . '<br/>';
echo 'option2: '. $Q_option2 . '<br/>';
echo 'option3: '. $Q_option3 . '<br/>';
echo 'option4: '. $Q_option4 . '<br/>';
echo 'correctAnswer: '. $Q_correctAnswer . '<br/>';
echo 'resource: '. $Q_resource . '<br/>';
}

////////////////////////////////////////////////////////////////////////
//										     		   QUESTION IN TEST
//////////////////////////////////////////////////////////////////////
function questionintest () {
$studentID = 136;
$testID = 1;
$con = mysqli_connect("localhost","root","Frankie28","dblr12aas");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries
$result = mysqli_query($con,"SELECT * FROM questionintest WHERE testID = "
. "'" . $testID . "'");

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	$QIT_itemID = $row["itemID"];
	$QIT_testID = $row["testID"];
	$QIT_id = $row["id"];
}

echo 'itemID: '. $QIT_itemID . '<br/>';
echo 'testID: '. $QIT_testID . '<br/>'; 
echo 'id: ' . $QIT_id . '<br/>';
}

////////////////////////////////////////////////////////////////////////
//										     		      RUN FUNCTIONS
//////////////////////////////////////////////////////////////////////
$question = question();
$questionintest = questionintest();
$student = student();
$studentintest = studentintest();
$studentResponse = studentresponse();
$test = test();
?> 
<ul>
<?php foreach($studentResponse as $response) {
	?><li><?php echo $response['studentID']; ?></li><?php
} ?>
</ul>
 </div>
</div>
</body>
</html>
